
import AbsWindow from "../../framework/AbsWindow";
import { WindowName } from "../../framework/reflect/WindowName";
import MenuWindow from "./MenuWindow";
import { WxEvent } from "../../framework/wx/WxEvent";
import Context from "../../framework/Context";
import LocalStorage from "../../framework/utils/LocalStorage";
import LoadResData from "../../framework/LoadResData";
import ListView from "../../framework/component/ListView";
import ListAdapter from "../comp/ListAdapter";
import FbItem from "../comp/FbItem";
const { ccclass, property } = cc._decorator;
@ccclass
@WindowName("FBWindow")
export default class FBWindow extends AbsWindow {

    @property(cc.Node)
    private returnBtn: cc.Node = null;
    @property (ListView)
    private dataListView:ListView = null;
    private timerList = [];
    private prefabList = [];
    private reward = 0;
    /*  public static sendData(data): Promise<FBWindow> {
         return Context.get().startWindow(FBWindow).then(FB => {
             FB.initData(data);
             return Promise.resolve(FB)
         })
     }
     public initData(data) {
 
     } */
    public onShow() {
        this.setClickListener(this.returnBtn, this.onReturnBtn);
        const adapter = new FbListAdapter();
        var fbData = [0,1,2,3,4,5,6,7];
        adapter.setDataSet(fbData)
        this.dataListView.setAdapter(adapter)
    }

    public listen(): string[] {
        return []
    }

    public handleMessage(message: string, args: any[]): boolean {
        switch (message) {
        }
        return false
    }
    private onReturnBtn() {
        this.context.closeWindow(FBWindow);
        for (let i = 0; i < this.timerList.length; i++) {
            clearTimeout(this.timerList[i])
        }

    }
   
}
export class FbListAdapter extends ListAdapter{

    public updateView(item: cc.Node, posIndex: number) {
        const comp = item.getComponent(FbItem)
        comp.setInfo(this.getItem(posIndex))
        
        
    }

} 